package com.scrx.ymg.dao.base;

import java.util.List;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport;

@Repository("baseDao")
@Transactional
public class BaseDaoImpl implements IBaseDao {
	protected SessionFactory sessionFactory;

    public void setSessionFactory(SessionFactory sessionFactory){
       this.sessionFactory = sessionFactory;
    }
     
    protected Session getCurrentSession(){
     return sessionFactory.getCurrentSession(); 
    }
    
    public String updateObject(Object object){
    	try {
    		this.getCurrentSession().update(object);
    		return "true";
		} catch (Exception e) {
			return "false";
		}
    	
    }
    public String insertObject(Object object){
    	try {
    		this.getCurrentSession().save(object);
    		return "true";
		} catch (Exception e) {
			return "false";
		}
    	
    }



}
